﻿using Sunny.UI;
using System;
using System.Windows.Forms;
using Toolbox.form.box;
using Toolbox.form.test.picture;
using Toolbox.util;

namespace Toolbox
{
    public partial class HomeForm : UIHeaderAsideMainFrame
    {
        public HomeForm()
        {
            InitializeComponent();
        }

        private void HomeForm_Load(object sender, EventArgs e)
        {
            InitView();
        }

        private void InitView()
        {
            this.Text = ApplicationUtils.BuildProductName();

            InitMenu();
        }

        private void InitMenu()
        {
            int pageIndex = 1000;
            Header.SetNodePageIndex(Header.Nodes[0], pageIndex);
            Header.SetNodeSymbol(Header.Nodes[0], 362566);
            TreeNode parent = Aside.CreateNode("宝盒", 362566, 24, pageIndex);

            //通过设置PageIndex关联，节点文字、图标由相应的Page的Text、Symbol提供
            Aside.CreateChildNode(parent, AddPage(new UuidForm(), ++pageIndex));
            Aside.CreateChildNode(parent, AddPage(new EncryptForm(), ++pageIndex));
            Aside.CreateChildNode(parent, AddPage(new TimeStampForm(), ++pageIndex));
            Aside.CreateChildNode(parent, AddPage(new BinaryConvertForm(), ++pageIndex));

            pageIndex = 2000;
            Header.SetNodePageIndex(Header.Nodes[1], pageIndex);
            Header.SetNodeSymbol(Header.Nodes[1], 363382);
            parent = Aside.CreateNode("网络", 363382, 24, pageIndex);
            Aside.CreateChildNode(parent, AddPage(new form.net.HttpForm(), ++pageIndex));

            pageIndex = 3000;
            Header.SetNodePageIndex(Header.Nodes[2], pageIndex);
            Header.SetNodeSymbol(Header.Nodes[2], 361832);
            parent = Aside.CreateNode("正在测试", 361832, 24, pageIndex);
            Aside.CreateChildNode(parent, AddPage(new PictureTestForm(), ++pageIndex));

            //选中第一个节点
            Aside.SelectPage(1001);
        }

        private void Header_MenuItemClick(string text, int menuIndex, int pageIndex)
        {
            switch (menuIndex)
            {
                case 4:
                    UIStyle style = (UIStyle)pageIndex;
                    if (style != UIStyle.Colorful)
                        StyleManager.Style = style;
                    else
                        SelectPage(pageIndex);

                    break;
                default:
                    Aside.SelectPage(pageIndex);
                    break;
            }
        }

        
    }
}
